<template>
<view class="container">
		<view class="top">
			<view class="f1">需支付金额</view>
			<view class="f2" ><text class="t1">￥</text><text class="t2">{{opt.money}}</text></view>
			
			<view class="f1">订单号</view>
			<view class="f3" ><text class="t3">{{opt.ordernum}}</text></view>
			
			<view class="f4">二维码</view>
			<view class="qr-box" style="margin: 30px;">
				<canvas canvas-id="qrcode" v-show="qrShow" style="width: 150px;margin: 0 auto;"/>
			</view>	
		</view>
</view>
</template>

<script>
var app = getApp();
import uQRCode from '@/static/js/uqrcode.js'

export default {
	data() {
		return {
			opt:{},
			loading:false,
			isload: false,
			ttitle:'',
			qrShow:false,
		};
	},

	onLoad: function (opt) {
		//this.opt = app.getopts(opt);
		
		this.opt = JSON.parse(decodeURIComponent(opt.dd))
		console.log(decodeURIComponent(opt.dd))
		this.opt = JSON.parse(opt.dd);
		console.log("二维码--参数：："+opt.dd);
		
		if(this.opt.buyType == 11){
					this.ttitle='微信';
				}else if(this.opt.buyType == 12){
					this.ttitle='支付宝';
				}else if(this.opt.buyType == 12){
					this.ttitle='银联';
				}else if(this.opt.buyType == 90){
					this.ttitle='云闪付';
				}
				console.log("二维码-code：："+this.opt.code);
		this.qrFun(this.opt.code)
	},
	onShow() {
		var tt = this;
	    this.timer = setInterval(function() {
			tt.cheng(tt.opt.ordernum)
	    }, 10000);
	},
	onUnload() {//离开页面前清除计时器
		var that = this;
	    clearInterval(that.timer);
	    that.timer = null;
	},
	
  methods: {
		//**生成二维码**//
		qrFun: function(text) {
			this.qrShow = true
			uQRCode.make({
				canvasId: 'qrcode',
				componentInstance: this,
				text: text,
				size: 150,
				margin: 0,
				backgroundColor: '#ffffff',
				foregroundColor: '#000000',
				fileType: 'jpg',
				errorCorrectLevel: uQRCode.errorCorrectLevel.H,
				success: res => {}
			})
		},
		gotourl:function(tourl, opentype){
			var that = this;
			if(app.globalData.platform == 'mp' || app.globalData.platform == 'h5'){
				if (tourl.indexOf('miniProgram::') === 0) {
					//其他小程序
					tourl = tourl.slice(13);
					var tourlArr = tourl.split('|');
					console.log(tourlArr)
					that.showOpenWeapp();
					return;
				}
			}
			app.goto(tourl, opentype);
		},
		cheng:function(onum){
			var that = this;
			app.post('ApiPay/lsscancheck', {ordernum: that.opt.ordernum}, function (res) {
				app.showLoading(false);
				if (res.status == 1) {
					that.gotourl(that.opt.tourl,'reLaunch');
					return;
				}
			});
			
		},
	
  }
}
</script>
<style>
.top{width:100%;display:flex;flex-direction:column;align-items:center;padding-top:60rpx}
.top .f1{height:60rpx;line-height:60rpx;color:#939393;font-size:24rpx;}
.top .f2{color:#101010;font-weight:bold;font-size:72rpx;height:120rpx;line-height:120rpx}
.top .f3{color:#101010;font-weight:bold;font-size:72rpx;height:40rpx;line-height:40rpx}
.top .f2 .t1{font-size:44rpx}
.top .f3 .t3{font-size:30rpx}
.top .f4{height:60rpx;line-height:120rpx;color:#939393;font-size:24rpx;}
</style>